﻿using UnityEngine;

namespace Nomo.UnityCoreModule
{
    /// <summary>
    /// 为 <see cref="UnityEngine.Color"/> 类型的实例提供扩展方法。
    /// </summary>
    public static class ColorExtension
    {
        /// <summary>
        /// 返回指定的颜色的灰度化颜色。
        /// </summary>
        /// <param name="color">颜色。</param>
        /// <returns>指定的颜色的灰度化颜色。</returns>
        public static Color Grayscale(this Color color)
        {
            var grayscale = color.grayscale;
            return new Color(grayscale, grayscale, grayscale, color.a);
        }

        /// <summary>
        /// 返回指定的颜色的反色。
        /// </summary>
        /// <param name="color">颜色。</param>
        /// <returns>指定的颜色的反色。</returns>
        public static Color Reverse(this Color color)
        {
            return new Color(1F - color.r, 1F - color.g, 1F - color.b, color.a);
        }
    }
}
